/*
	part.h for HBIOS
*/

#if !defined( _PART_H )
#define _PART_H

#define PART_BIOS		0
#define BIOS_ID1		0x55
#define BIOS_ID2		0xaa
#define ID_MAC_CODE		0x8888
#define ID_PTI			0x7777

//For all partion
//PTI at offset 0x180 of ended sector
//Vesion code at offset 0x1fe of ended sector

//For BIOS partion
//BIOS_ID1,BIOS_ID2 at offset 0x000 of first sector
//MAC_BIN at offset 0x100 of ended sector

//For LOGO partion
//LCD Mode at offset 0x1ff of ended sector

#define DEV_5INCH	0	//160K/320K,180K/360K
#define DEV_5INCH1200KB	1	//1.2M
#define DEV_3INCH720KB	2	//720K
#define DEV_8INCHSS	3	//
#define DEV_8INCHDS	4	//
#define DEV_HARDDISK	5	//
#define DEV_OTHER	7	//
#define DEV_3INCH1440KB	7	//1.44M
#define DEV_3INCH2880KB	9	//2.88M

#define FLAG_WR_EN	0x8000
#define FLAG_SRAM	0x4000
#define FLAG_FLASH	0x2000
#define FLAG_DISK	0x0800
#define FLAG_CHKSUM	0x0200
#define FLAG_BACKUP	0x0100
#define FLAG_USE_XMS 	0x0080

#if !defined(__BPB_T)
#define __BPB_T

struct bpb_t
{
	unsigned int  bytes_per_sector;		//number of bytes per sector
	unsigned char sectors_per_cluster;	//number of sectors per cluster
	unsigned int  reserved_sectors;		//number of reserved sectors
	unsigned char number_of_FATs;		//number of FATs
	unsigned int  root_entries;		//number of root directory slots
	unsigned int  total_sectors;		//total number of sectors
	unsigned char media_descriptor;	 	//Media description
	unsigned int  sectors_per_FAT;		//number of sectors per FAT
	unsigned int  sectors_per_track;	//number of sectors per track
	unsigned int  number_of_heads;		//number of heads
	unsigned long hidden_sectors; 		//number of hidden sectors
	unsigned long total_sectors_32; 	//32-bit number of sectors
};
#endif

#if !defined(__rBPB_T)
#define __rBPB_T

struct rbpb_t
{
	unsigned int  bytes_per_sector;		//number of bytes per sector
	unsigned char sectors_per_cluster;	//number of sectors per cluster
	unsigned int  reserved_sectors;		//number of reserved sectors
	unsigned char number_of_FATs;		//number of FATs
	unsigned int  root_entries;		//number of root directory slots
	unsigned int  total_sectors;		//total number of sectors
	unsigned char media_descriptor;	 	//Media description
	unsigned int  sectors_per_FAT;		//number of sectors per FAT
	unsigned int  sectors_per_track;	//number of sectors per track
	unsigned int  number_of_heads;		//number of heads
	unsigned long hidden_sectors; 		//number of hidden sectors
	unsigned long total_sectors_32; 	//32-bit number of sectors
	unsigned char form_factor;		// Driver type
};
#endif

#if !defined(__PART_ATT_T)
#define __PART_ATT_T

struct part_att_t   //58 bytes
{
	unsigned int next;
	char no;
	unsigned int  flag;
	unsigned char name[15];
	unsigned long dat_sectors;
	unsigned long tot_sectors;
	unsigned long beg_sector;
	struct rbpb_t rbpb; //26 bytes
};
#endif

#if !defined(__PART_DATA_T)
#define __PART_DATA_T
struct part_data_t //59 bytes
{
	unsigned int beg_sector;
	char drive;
	unsigned int flag;
	unsigned long xms_beg;
	unsigned char vol_id[12];
	unsigned long serial;
	unsigned char filesystem[8];
	struct bpb_t bpb; //25 bytes
	unsigned char cylinders;
};

#endif

#if !defined(__PART_INFO_T)
#define __PART_INFO_T

#define DATT_WR_EN		0x8000
#define DATT_SRAM		0x4000
#define DATT_FLASH		0x2000
#define DATT_NON_REMOVABLE 	0x0001

struct part_info_t   //total 55 bytes
{
	unsigned int id; //id=8888 for extended media id packet
	unsigned long serial; //rw*
	unsigned char label[11]; //rw*
	unsigned char filesystem[8]; //rw* above is the same as mediaidpacket_t
	unsigned char name[15];  //ro* below is the extended information for hcnc ssd
	char no; //ro*
	char drive; //ro*
	unsigned int  flag; //ro*
	unsigned int  version; //rw*
	unsigned char year,month,day; //rw*
	long total_sectors; //ro*
};

#endif

#endif
